import {Component, Input, OnInit} from '@angular/core';
import {_HttpClient} from '@delon/theme';
import {NzMessageService, NzModalSubject} from 'ng-zorro-antd';
import {UserShow} from '../../show/show.modle';
import {UserService} from '../../user.service';

@Component({
    selector: 'app-editpwd',
    templateUrl: './editpwd.component.html',
    styles: [`
        :host ::ng-deep .customize-footer {
            border-top: 1px solid #e9e9e9;
            padding: 10px 18px 0 10px;
            text-align: right;
            border-radius: 0 0 0px 0px;
            margin: 15px -16px -5px -16px;
        }

        button {
            margin-left: 10px;
        }

    `]
})
export class EditpwdComponent implements OnInit {
    password;
    _id: number;

    @Input()
    set id(value: number) {
        this._id = value;
    }

    constructor(
        private http: _HttpClient,
        private subject: NzModalSubject,
        private userService: UserService,
        private msg: NzMessageService,
    ) {
    }

    ngOnInit() {
    }

    handleCancel(e) {
        this.subject.destroy('onCancel');
    }

    sendpwd(e) {
        console.log('+++++++++++++++++id' + this._id);
        console.log('-----------密码------------------' + this.password);
        this.userService.resetpwd(this._id, this.password).subscribe(res => {
            this.subject.destroy('onOk');
            this.msg.success('修改成功');
        });
    }
}
